Make a java script function.
Call that function based on an event response. This can be combined with your first JS assignment.